package com.zretc.util;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2020/8/22.
 */
@Component
public class RBMQReceiver {
    @RabbitListener(queues="topic.message")    //监听器监听指定的Queue,发现消息便传给websocket
    public void process1(String str) {
        System.out.println("message:"+str);
        String receiverId = str.split(",")[0];
        String msg = str.split(",")[1];
        System.out.println("receiverId:"+receiverId);
        Chatman user = Chatman.chatroom.get(receiverId);
        user.sendMessage("msg","rbmqreceive"+msg);
    }
    @RabbitListener(queues="topic.messages")    //监听器监听指定的Queue,监听器监听指定的Queue,发现消息便传给websocket
    public void  process2(String str) {
        System.out.println("messages:"+str);
    }
}
